package lab02.text11;

public class Rectangle implements Printx  {
    //求面积、求周长的方法

    double length;
    double width;

    Rectangle(){}

    Rectangle(double length,double width){
        this.length = length;
        this.width = width;
    }

    double area(){
        return length*width;
    }
    double perimeter(){
        return 2*length+2*width;
    }

    public void setLength(double length) {
        this.length = length;
    }

    public double getLength() {
        return length;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getWidth() {
        return width;
    }

    //printMyWay()方法要能显示矩形的边长、面积和周长

    @Override
    public void printMyWay() {
        System.out.println("长："+length+"\n"+
                "宽："+width+"\n"+"面积："+area()+"\n"+
                "周长："+perimeter()+"\n");

    }
}
